package com.yulongtian.oneProblemEveryDay.month202211.day20221129;

/**
 * https://leetcode.cn/problems/decompress-run-length-encoded-list/submissions/
 * 可
 *
 * @author yulongTian
 * @create 2022-11-29 16:20
 */
public class Test04 {
    public static void main(String[] args) {

    }

    public static int[] decompressRLElist(int[] nums) {

        int len = 0;
        for (int i = 0; i < nums.length; i += 2) {
            len += nums[i];
        }
        int[] res = new int[len];
        int index = 0;
        for (int i = 0; i < nums.length; i += 2) {
            for (int j = 0; j < nums[i]; j++) {
                res[index++] = nums[i + 1];
            }
        }
        return res;
    }

}
